package com.example.zhihuigongdi.controller;


import com.example.zhihuigongdi.entity.Machinery;
import com.example.zhihuigongdi.entity.Personnel;
import com.example.zhihuigongdi.entity.respon.Result;
import com.example.zhihuigongdi.service.IMachineryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import sun.dc.pr.PRError;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liuhongbin
 * @since 2024-04-17
 */
@RestController
@RequestMapping("/machinery")
public class MachineryController {
    @Autowired
    private IMachineryService machineryService;

    @PostMapping("/list/{current}/{size}")
    public Result list(@PathVariable int current, @PathVariable int size){
        return machineryService.getMachinery(current,size);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Machinery machinery){
        return machineryService.addMachinery(machinery);
    }

    @PostMapping("/add/{machineryId}")
    public Result remove(@PathVariable int machineryId ){
        return machineryService.removeMachinery(machineryId);
    }
    @PostMapping("/update")
    public Result update(@RequestBody Machinery machinery){
        return machineryService.updateStatus(machinery);
    }
}
